import instance from "../utils/request"
import Vue from "vue"
import router from "../router"
import { Notify } from 'vant';
import {base_url} from '../utils/baseURL'
export default {
    namespaced:true,
    state:()=>({
        addressList:null,
        goods:[{}]
    }),
    mutations:{
        addrgoods(state,obj){
            // console.log(state.goods)
            state.goods.splice(0,1,obj)
            // console.log(state.goods)
        },
        addressAddMut(state,adrs){
                state.addressList.push(adrs)    
        },
        addressAddDeta(state,i){
            console.log(state.addressList)
            state.addressList.splice(i,1)
        },
        addressModify(state,{content,id}){
            
            state.addressList[id]=content
            console.log(state.addressList)
        },
        getAddressMut(state,obj){
            state.addressList = obj;
        }
    },
    actions:{
        addressAddAct(context,obj){
            context.commit('addressAddMut',obj);
            let url = `${base_url}address`;
            instance.post(url,obj).then(res=>{
                console.log(res);
            })
        }
    }
}
